package river_city_ransom.contracts;

import exceptions.ComposantError;
import exceptions.PostconditionError;
import river_city_ransom.decorators.Position_D;
import river_city_ransom.services.Position;


public class Position_C extends Position_D {
	public Position_C(Position delegate) {
		super(delegate);
	}
	
	@Override
	public String toString() {
		return super.toString();
	}
	
	/** _________________________________________________________ OBSERVATORS */
	@Override
	public int x() {
		return super.x();
	}

	@Override
	public int y() {
		return super.y();
	}

	@Override
	public int z() {
		return super.z();
	}

	/** ________________________________________________________ CONSTRUCTORS */
	@Override
	public void init(int x, int y, int z) throws ComposantError {
		super.init(x, y, z);
		
		boolean post;
//		post x(init(x, y, z)) = x
		post = x() == x;
		if(!post) {
			throw new PostconditionError("x(init(x, y, z)) = x");
		}
//		post y(init(x, y, z)) = y
		post = y() == y;
		if(!post) {
			throw new PostconditionError("y(init(x, y, z)) = y");
		}
//		post z(init(x, y, z)) = z
		post = z() == z;
		if(!post) {
			throw new PostconditionError("z(init(x, y, z)) = z");
		}
	}
}
